//
//  HNSH_ExchangeRecordCell.m
//  HNSH_SingleProject
//
//  Created by 李宇廷 on 2023/4/24.
//

#import "HNSH_ExchangeRecordCell.h"

@interface HNSH_ExchangeRecordCell ()

/* bgView */
@property (nonatomic, strong) UIView *bgView;

/* tagLabel */
@property (nonatomic, strong) UILabel *orderNoLabel;
/* statusLabel */
@property (nonatomic, strong) UILabel *statusLabel;

/* 购买类型： */
@property (nonatomic, strong) UILabel *typeTitleLabel;
/* 购买类型： */
@property (nonatomic, strong) UILabel *typeLabel;

/* 充值手机号/卡号： */
@property (nonatomic, strong) UILabel *idCardTitleLabel;
/* 充值手机号/卡号： */
@property (nonatomic, strong) UILabel *idCardLabel;

/* 价格： */
@property (nonatomic, strong) UILabel *priceTitleLabel;
/* 价格： */
@property (nonatomic, strong) UILabel *priceLabel;

/* 赠送积分： */
@property (nonatomic, strong) UILabel *jfTitleLabel;
/* 赠送积分： */
@property (nonatomic, strong) UILabel *jfLabel;

/* 创建时间： */
@property (nonatomic, strong) UILabel *timeTitleLabel;
/* 创建时间： */
@property (nonatomic, strong) UILabel *timeLabel;

@end

@implementation HNSH_ExchangeRecordCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = [UIColor appBGColor];
        [self configView];
    }
    return self;
}

- (void)setModel:(HNSH_ExchangeRecordModel *)model {
    _model = model;
    //订单状态 10:待付款 20:充值中 100:充值完成 110:已取消 120:充值失败 200:已退款
    if ([model.status integerValue] == 10) {
        self.statusLabel.text = @"待付款";
        self.statusLabel.textColor = [UIColor appGreenColor];
    } else if ([model.status integerValue] == 20) {
        self.statusLabel.text = @"处理中";
        self.statusLabel.textColor = [UIColor appGreenColor];
    } else if ([model.status integerValue] == 100) {
        self.statusLabel.text = @"完成";
        self.statusLabel.textColor = [UIColor colorWithHexString:@"#027AFF"];
    } else if ([model.status integerValue] == 110) {
        self.statusLabel.text = @"已取消";
        self.statusLabel.textColor = [UIColor appGreenColor];
    } else if ([model.status integerValue] == 120) {
        self.statusLabel.text = @"失败";
        self.statusLabel.textColor = [UIColor appGreenColor];
    } else if ([model.status integerValue] == 200) {
        self.statusLabel.text = @"已退款";
        self.statusLabel.textColor = [UIColor appGreenColor];
    }
    self.orderNoLabel.text = [NSString stringWithFormat:@"订单号：%@",model.order_no];
    self.typeLabel.text = model.product_name;
    self.idCardLabel.text = model.account;
    self.priceLabel.text = [NSString stringWithFormat:@"%.2f",[model.total_price doubleValue]];
    self.jfLabel.text = [NSString stringWithFormat:@"%.2f",[model.total_consumer_reward doubleValue]];
    self.timeLabel.text = model.create_time;
}

- (void)configView {
    [self.contentView addSubview:self.bgView];
    
    [self.bgView addSubview:self.orderNoLabel];
    [self.bgView addSubview:self.statusLabel];
    
    [self.bgView addSubview:self.typeTitleLabel];
    [self.bgView addSubview:self.typeLabel];
    
    [self.bgView addSubview:self.idCardTitleLabel];
    [self.bgView addSubview:self.idCardLabel];
    
    [self.bgView addSubview:self.priceTitleLabel];
    [self.bgView addSubview:self.priceLabel];
    
    [self.bgView addSubview:self.jfTitleLabel];
    [self.bgView addSubview:self.jfLabel];
    
    [self.bgView addSubview:self.timeTitleLabel];
    [self.bgView addSubview:self.timeLabel];
    
    [self.orderNoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.top.mas_equalTo(12);
        make.height.mas_equalTo(22);
    }];
    
    [self.statusLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-20);
        make.top.mas_equalTo(12);
        make.height.mas_equalTo(22);
    }];
    
    UIView *line = [[UIView alloc]init];
    line.backgroundColor = [UIColor colorWithHexString:@"#EDEDED"];
    [self.bgView addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(14);
        make.right.mas_equalTo(-14);
        make.top.mas_equalTo(44);
        make.height.mas_equalTo(1);
    }];
    
    [self.typeTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.top.mas_equalTo(50);
        make.height.mas_equalTo(20);
    }];
    [self.typeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-20);
        make.centerY.equalTo(self.typeTitleLabel.mas_centerY);
        make.height.mas_equalTo(20);
    }];
    
    [self.idCardTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.top.equalTo(self.typeTitleLabel.mas_bottom).offset(6);
        make.height.mas_equalTo(20);
    }];
    [self.idCardLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-20);
        make.centerY.equalTo(self.idCardTitleLabel.mas_centerY);
        make.height.mas_equalTo(20);
    }];
    
    [self.priceTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.top.equalTo(self.idCardTitleLabel.mas_bottom).offset(6);
        make.height.mas_equalTo(20);
    }];
    [self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-20);
        make.centerY.equalTo(self.priceTitleLabel.mas_centerY);
        make.height.mas_equalTo(20);
    }];
    
    [self.jfTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.top.equalTo(self.priceTitleLabel.mas_bottom).offset(6);
        make.height.mas_equalTo(20);
    }];
    [self.jfLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-20);
        make.centerY.equalTo(self.jfTitleLabel.mas_centerY);
        make.height.mas_equalTo(20);
    }];
    
    [self.timeTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.top.equalTo(self.jfTitleLabel.mas_bottom).offset(6);
        make.height.mas_equalTo(20);
    }];
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-20);
        make.centerY.equalTo(self.timeTitleLabel.mas_centerY);
        make.height.mas_equalTo(20);
    }];
}

#pragma mark lazy
- (UIView *)bgView {
    if (!_bgView) {
        _bgView = [[UIView alloc]initWithFrame:CGRectMake(20, 0, kScreenWidth-40, 194)];
        _bgView.backgroundColor = [UIColor appWhiteLabelColor];
        _bgView.layer.cornerRadius = 8.0f;
        _bgView.layer.masksToBounds = YES;
    }
    return _bgView;
}

- (UILabel *)orderNoLabel {
    if (!_orderNoLabel) {
        _orderNoLabel = [[UILabel alloc]init];
        _orderNoLabel.text = @"订单号：";
        _orderNoLabel.textColor = [UIColor appBlackLabelColor];
        _orderNoLabel.font = [UIFont boldSystemFontOfSize:16];
    }
    return _orderNoLabel;
}

- (UILabel *)statusLabel {
    if (!_statusLabel) {
        _statusLabel = [[UILabel alloc]init];
        _statusLabel.text = @"处理中";
        _statusLabel.textColor = [UIColor appGreenColor];
        _statusLabel.font = [UIFont systemFontOfSize:14];
    }
    return _statusLabel;
}

- (UILabel *)typeTitleLabel {
    if (!_typeTitleLabel) {
        _typeTitleLabel = [[UILabel alloc]init];
        _typeTitleLabel.text = @"购买类型：";
        _typeTitleLabel.textColor = [UIColor appGrayLabelColor];
        _typeTitleLabel.font = [UIFont systemFontOfSize:14];
    }
    return _typeTitleLabel;
}

- (UILabel *)typeLabel {
    if (!_typeLabel) {
        _typeLabel = [[UILabel alloc]init];
        _typeLabel.text = @"电费";
        _typeLabel.textColor = [UIColor appBlackLabelColor];
        _typeLabel.font = [UIFont boldSystemFontOfSize:14];
    }
    return _typeLabel;
}

- (UILabel *)idCardTitleLabel {
    if (!_idCardTitleLabel) {
        _idCardTitleLabel = [[UILabel alloc]init];
        _idCardTitleLabel.text = @"充值手机号/卡号：";
        _idCardTitleLabel.textColor = [UIColor appGrayLabelColor];
        _idCardTitleLabel.font = [UIFont systemFontOfSize:14];
    }
    return _idCardTitleLabel;
}

- (UILabel *)idCardLabel {
    if (!_idCardLabel) {
        _idCardLabel = [[UILabel alloc]init];
        _idCardLabel.text = @"电费";
        _idCardLabel.textColor = [UIColor appBlackLabelColor];
        _idCardLabel.font = [UIFont boldSystemFontOfSize:14];
    }
    return _idCardLabel;
}

- (UILabel *)priceTitleLabel {
    if (!_priceTitleLabel) {
        _priceTitleLabel = [[UILabel alloc]init];
        _priceTitleLabel.text = @"价格：";
        _priceTitleLabel.textColor = [UIColor appGrayLabelColor];
        _priceTitleLabel.font = [UIFont systemFontOfSize:14];
    }
    return _priceTitleLabel;
}

- (UILabel *)priceLabel {
    if (!_priceLabel) {
        _priceLabel = [[UILabel alloc]init];
        _priceLabel.text = @"电费";
        _priceLabel.textColor = [UIColor appBlackLabelColor];
        _priceLabel.font = [UIFont boldSystemFontOfSize:14];
    }
    return _priceLabel;
}

- (UILabel *)jfTitleLabel {
    if (!_jfTitleLabel) {
        _jfTitleLabel = [[UILabel alloc]init];
        _jfTitleLabel.text = @"赠送积分：";
        _jfTitleLabel.textColor = [UIColor appGrayLabelColor];
        _jfTitleLabel.font = [UIFont systemFontOfSize:14];
    }
    return _jfTitleLabel;
}

- (UILabel *)jfLabel {
    if (!_jfLabel) {
        _jfLabel = [[UILabel alloc]init];
        _jfLabel.text = @"电费";
        _jfLabel.textColor = [UIColor appBlackLabelColor];
        _jfLabel.font = [UIFont boldSystemFontOfSize:14];
    }
    return _jfLabel;
}

- (UILabel *)timeTitleLabel {
    if (!_timeTitleLabel) {
        _timeTitleLabel = [[UILabel alloc]init];
        _timeTitleLabel.text = @"创建时间：";
        _timeTitleLabel.textColor = [UIColor appGrayLabelColor];
        _timeTitleLabel.font = [UIFont systemFontOfSize:14];
    }
    return _timeTitleLabel;
}

- (UILabel *)timeLabel {
    if (!_timeLabel) {
        _timeLabel = [[UILabel alloc]init];
        _timeLabel.text = @"电费";
        _timeLabel.textColor = [UIColor appBlackLabelColor];
        _timeLabel.font = [UIFont boldSystemFontOfSize:14];
    }
    return _timeLabel;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
